<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<title></title>
</head>
<body>
<input type="text" id="latitude" value="" style="display: none;" />
<input type="text" id="longitude" value="" style="display: none;" />
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
var latitude = 0;
var longitude = 0;
var marker1='';
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(116.627067,39.807332), 11);
map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
//map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}));  //右上角，仅包含平移和缩放按钮
//map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT, type: BMAP_NAVIGATION_CONTROL_PAN}));  //左下角，仅包含平移按钮
//map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM}));  //右下角，仅包含缩放按钮
map.addEventListener("click", showInfo);

//地图上加一个点，原始点
var marker1 = new BMap.Marker(new BMap.Point(116.627067,39.807332));
map.addOverlay(marker1);
marker1.addEventListener("click", function(){this.openInfoWindow(new BMap.InfoWindow("标记1"));});

function showInfo(e){
    map.removeOverlay(marker1);
    marker1 = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat));
    map.addOverlay(marker1);
    document.getElementById('latitude').value=e.point.lng;
    document.getElementById('longitude').value=e.point.lat;
}
</script>


